#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
# ex7-5 
# write a subroutine that,given a coden(a fragment of DNA of length3),
# return a random mutation in the codon.
my $coden = "ATC";

my @nucleotides = ('A','T','G','C');

my $position = random_position($coden);
my $random_nucleotide = random_nucleotide(@nucleotides);

substr($coden,$position,1,$random_nucleotide);
say "mutant:$coden";

sub random_position{
	my($string) = @_;
	return int rand length $string;
}

sub random_nucleotide{

	my(@nucleotides) = @_;
	return $nucleotides[rand @nucleotides];
}
